#!/usr/bin/env python
# -*- coding:utf-8 -*-
import pika

# ########################## 消费者 ##########################

connection = pika.BlockingConnection(pika.ConnectionParameters(host='192.168.136.8'))
channel = connection.channel()

channel.queue_declare(queue='hello')    #声明，队列名称，和producer创建的重复没有关系

def callback(ch, method, properties, body):
    print(" [x] Received %r" % body)

channel.basic_consume(callback,
                      queue='hello',
                      no_ack=True)

print(' [*] Waiting for messages. To exit press CTRL+C')
channel.start_consuming()